# LocGrab-Connect, py

## Map user to the nearest server based on locale

### Setup
Windows
1. Install python3.5 or newer.
2. Run the file by double-clicking.

### Linux
1. Place the file in a separate folder.
2. Open terminal, change directory to the file directory ( cd ... )
3. Enter python3 `LocMatch.py`

## Development
A sample python script was used from ipwhois.app to begin the development process. To
have user location match with the nearest "server", an array is initialized and the script sends
a request to the API. The user can append an IP address of their liking or use the automatic
mode, where necessary data is retrieved. If the user lives in a country that matches the list
(e.g. the array), the script will print the data normally. Otherwise, a failure notification will be
outputted.\

## Drawbacks to current implementation
1. The array list, while scalable, could become unsustainably large due to the number of
countries within the same region, or just the fact that there are a lot of countries in the
world.
2. The index combo from the array (e.g. ``[('PL', 'eu-central-1')]`` ) is printed even
though the country code, parentheses and apostrophes may appear as redundant for
users.
3. ``try...except..`` could be expanded to show users of possible factors for failure to send
a request to the API.

## Milestones

### Error handling

- ~~Script response to API unavailability~~
- ~~Out-of-bounds response~~

# Sources used
1. AWS (Amazon Web Services) Documentation - Regions and Zones,
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions
2. IPWHOIS.APP Documentation, https://ipwhois.io/documentation